
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>接口 · TypeScript Handbook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Patrick Zhong">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Classes.html" />
    
    
    <link rel="prev" href="Variable Declarations.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="tutorials/">
            
                <a href="tutorials/">
            
                    
                    快速上手
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="tutorials/TypeScript in 5 minutes.html">
            
                <a href="tutorials/TypeScript in 5 minutes.html">
            
                    
                    5分钟了解TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="tutorials/ASP.NET Core.html">
            
                <a href="tutorials/ASP.NET Core.html">
            
                    
                    ASP.NET Core
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="tutorials/ASP.NET 4.html">
            
                <a href="tutorials/ASP.NET 4.html">
            
                    
                    ASP.NET 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="tutorials/Gulp.html">
            
                <a href="tutorials/Gulp.html">
            
                    
                    Gulp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="tutorials/Knockout.html">
            
                <a href="tutorials/Knockout.html">
            
                    
                    Knockout.js
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="tutorials/React & Webpack.html">
            
                <a href="tutorials/React & Webpack.html">
            
                    
                    React与webpack
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="tutorials/React.html">
            
                <a href="tutorials/React.html">
            
                    
                    React
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="tutorials/Angular 2.html">
            
                <a href="tutorials/Angular 2.html">
            
                    
                    Angular 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="tutorials/Migrating from JavaScript.html">
            
                <a href="tutorials/Migrating from JavaScript.html">
            
                    
                    从JavaScript迁移到TypeScript
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    手册
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="Basic Types.html">
            
                <a href="Basic Types.html">
            
                    
                    基础类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="Variable Declarations.html">
            
                <a href="Variable Declarations.html">
            
                    
                    变量声明
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.3" data-path="Interfaces.html">
            
                <a href="Interfaces.html">
            
                    
                    接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="Classes.html">
            
                <a href="Classes.html">
            
                    
                    类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="Functions.html">
            
                <a href="Functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="Generics.html">
            
                <a href="Generics.html">
            
                    
                    泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="Enums.html">
            
                <a href="Enums.html">
            
                    
                    枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="Type Inference.html">
            
                <a href="Type Inference.html">
            
                    
                    类型推论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="Type Compatibility.html">
            
                <a href="Type Compatibility.html">
            
                    
                    类型兼容性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="Advanced Types.html">
            
                <a href="Advanced Types.html">
            
                    
                    高级类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="Utilit Types.md">
            
                <span>
            
                    
                    实用工具类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.12" data-path="Symbols.html">
            
                <a href="Symbols.html">
            
                    
                    Symbols
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="Iterators and Generators.html">
            
                <a href="Iterators and Generators.html">
            
                    
                    Iterators 和 Generators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.14" data-path="Modules.html">
            
                <a href="Modules.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.15" data-path="Namespaces.html">
            
                <a href="Namespaces.html">
            
                    
                    命名空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.16" data-path="Namespaces and Modules.html">
            
                <a href="Namespaces and Modules.html">
            
                    
                    命名空间和模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.17" data-path="Module Resolution.html">
            
                <a href="Module Resolution.html">
            
                    
                    模块解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.18" data-path="Declaration Merging.html">
            
                <a href="Declaration Merging.html">
            
                    
                    声明合并
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.19" data-path="Writing Definition Files.html">
            
                <a href="Writing Definition Files.html">
            
                    
                    书写.d.ts文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.20" data-path="JSX.html">
            
                <a href="JSX.html">
            
                    
                    JSX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.21" data-path="Decorators.html">
            
                <a href="Decorators.html">
            
                    
                    Decorators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.22" data-path="Mixins.html">
            
                <a href="Mixins.html">
            
                    
                    混入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.23" data-path="Triple-Slash Directives.html">
            
                <a href="Triple-Slash Directives.html">
            
                    
                    三斜线指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.24" data-path="Type Checking JavaScript Files.html">
            
                <a href="Type Checking JavaScript Files.html">
            
                    
                    JavaScript文件里的类型检查
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="declaration files/Introduction.html">
            
                <a href="declaration files/Introduction.html">
            
                    
                    如何书写声明文件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="declaration files/Library Structures.html">
            
                <a href="declaration files/Library Structures.html">
            
                    
                    结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="declaration files/Do's and Don'ts.html">
            
                <a href="declaration files/Do's and Don'ts.html">
            
                    
                    规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="declaration files/By Example.html">
            
                <a href="declaration files/By Example.html">
            
                    
                    举例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="declaration files/Deep Dive.html">
            
                <a href="declaration files/Deep Dive.html">
            
                    
                    深入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="declaration files/Publishing.html">
            
                <a href="declaration files/Publishing.html">
            
                    
                    发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="declaration files/Consumption.html">
            
                <a href="declaration files/Consumption.html">
            
                    
                    使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="tsconfig.json.html">
            
                <a href="tsconfig.json.html">
            
                    
                    工程配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="tsconfig.json.html">
            
                <a href="tsconfig.json.html">
            
                    
                    tsconfig.json
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="Project References.html">
            
                <a href="Project References.html">
            
                    
                    工程引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="Typings for NPM Packages.html">
            
                <a href="Typings for NPM Packages.html">
            
                    
                    NPM包的类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="Compiler Options.html">
            
                <a href="Compiler Options.html">
            
                    
                    编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="Configuring Watch.html">
            
                <a href="Configuring Watch.html">
            
                    
                    配置 Watch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="Compiler Options in MSBuild.html">
            
                <a href="Compiler Options in MSBuild.html">
            
                    
                    在MSBuild里使用编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="Integrating with Build Tools.html">
            
                <a href="Integrating with Build Tools.html">
            
                    
                    与其它构建工具整合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="Nightly Builds.html">
            
                <a href="Nightly Builds.html">
            
                    
                    使用TypeScript的每日构建版本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../wiki/">
            
                <a href="../wiki/">
            
                    
                    Wiki
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../wiki/this-in-TypeScript.html">
            
                <a href="../wiki/this-in-TypeScript.html">
            
                    
                    TypeScript里的this
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../wiki/coding_guidelines.html">
            
                <a href="../wiki/coding_guidelines.html">
            
                    
                    编码规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../wiki/Common Errors.html">
            
                <a href="../wiki/Common Errors.html">
            
                    
                    常见编译错误
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../wiki/TypeScript-Editor-Support.html">
            
                <a href="../wiki/TypeScript-Editor-Support.html">
            
                    
                    支持TypeScript的编辑器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                <a href="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                    
                    结合ASP.NET v5使用TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../wiki/Architectural-Overview.html">
            
                <a href="../wiki/Architectural-Overview.html">
            
                    
                    架构概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../wiki/Roadmap.html">
            
                <a href="../wiki/Roadmap.html">
            
                    
                    发展路线图
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../release-notes/">
            
                <a href="../release-notes/">
            
                    
                    新增功能
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../release-notes/TypeScript 3.1.html">
            
                <a href="../release-notes/TypeScript 3.1.html">
            
                    
                    TypeScript 3.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../release-notes/TypeScript 3.0.html">
            
                <a href="../release-notes/TypeScript 3.0.html">
            
                    
                    TypeScript 3.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../release-notes/TypeScript 2.9.html">
            
                <a href="../release-notes/TypeScript 2.9.html">
            
                    
                    TypeScript 2.9
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../release-notes/TypeScript 2.8.html">
            
                <a href="../release-notes/TypeScript 2.8.html">
            
                    
                    TypeScript 2.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../release-notes/TypeScript 2.7.html">
            
                <a href="../release-notes/TypeScript 2.7.html">
            
                    
                    TypeScript 2.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../release-notes/TypeScript 2.6.html">
            
                <a href="../release-notes/TypeScript 2.6.html">
            
                    
                    TypeScript 2.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../release-notes/TypeScript 2.5.html">
            
                <a href="../release-notes/TypeScript 2.5.html">
            
                    
                    TypeScript 2.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="../release-notes/TypeScript 2.4.html">
            
                <a href="../release-notes/TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="../release-notes/TypeScript 2.3.html">
            
                <a href="../release-notes/TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.10" data-path="../release-notes/TypeScript 2.2.html">
            
                <a href="../release-notes/TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.11" data-path="../release-notes/TypeScript 2.1.html">
            
                <a href="../release-notes/TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.12" data-path="../release-notes/TypeScript 2.0.html">
            
                <a href="../release-notes/TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.13" data-path="../release-notes/TypeScript 1.8.html">
            
                <a href="../release-notes/TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.14" data-path="../release-notes/TypeScript 1.7.html">
            
                <a href="../release-notes/TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.15" data-path="../release-notes/TypeScript 1.6.html">
            
                <a href="../release-notes/TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.16" data-path="../release-notes/TypeScript 1.5.html">
            
                <a href="../release-notes/TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.17" data-path="../release-notes/TypeScript 1.4.html">
            
                <a href="../release-notes/TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.18" data-path="../release-notes/TypeScript 1.3.html">
            
                <a href="../release-notes/TypeScript 1.3.html">
            
                    
                    TypeScript 1.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.19" data-path="../release-notes/TypeScript 1.1.html">
            
                <a href="../release-notes/TypeScript 1.1.html">
            
                    
                    TypeScript 1.1
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../breaking-changes/breaking-changes.html">
            
                <a href="../breaking-changes/breaking-changes.html">
            
                    
                    Breaking Changes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../breaking-changes/TypeScript 2.4.html">
            
                <a href="../breaking-changes/TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../breaking-changes/TypeScript 2.3.html">
            
                <a href="../breaking-changes/TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../breaking-changes/TypeScript 2.2.html">
            
                <a href="../breaking-changes/TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../breaking-changes/TypeScript 2.1.html">
            
                <a href="../breaking-changes/TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../breaking-changes/TypeScript 2.0.html">
            
                <a href="../breaking-changes/TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../breaking-changes/TypeScript 1.8.html">
            
                <a href="../breaking-changes/TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../breaking-changes/TypeScript 1.7.html">
            
                <a href="../breaking-changes/TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../breaking-changes/TypeScript 1.6.html">
            
                <a href="../breaking-changes/TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../breaking-changes/TypeScript 1.5.html">
            
                <a href="../breaking-changes/TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="../breaking-changes/TypeScript 1.4.html">
            
                <a href="../breaking-changes/TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >接口</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4ECB;&#x7ECD;">&#x4ECB;&#x7ECD;</h1>
<p>TypeScript&#x7684;&#x6838;&#x5FC3;&#x539F;&#x5219;&#x4E4B;&#x4E00;&#x662F;&#x5BF9;&#x503C;&#x6240;&#x5177;&#x6709;&#x7684;<em>&#x7ED3;&#x6784;</em>&#x8FDB;&#x884C;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x3002;
&#x5B83;&#x6709;&#x65F6;&#x88AB;&#x79F0;&#x505A;&#x201C;&#x9E2D;&#x5F0F;&#x8FA8;&#x578B;&#x6CD5;&#x201D;&#x6216;&#x201C;&#x7ED3;&#x6784;&#x6027;&#x5B50;&#x7C7B;&#x578B;&#x5316;&#x201D;&#x3002;
&#x5728;TypeScript&#x91CC;&#xFF0C;&#x63A5;&#x53E3;&#x7684;&#x4F5C;&#x7528;&#x5C31;&#x662F;&#x4E3A;&#x8FD9;&#x4E9B;&#x7C7B;&#x578B;&#x547D;&#x540D;&#x548C;&#x4E3A;&#x4F60;&#x7684;&#x4EE3;&#x7801;&#x6216;&#x7B2C;&#x4E09;&#x65B9;&#x4EE3;&#x7801;&#x5B9A;&#x4E49;&#x5951;&#x7EA6;&#x3002;</p>
<h1 id="&#x63A5;&#x53E3;&#x521D;&#x63A2;">&#x63A5;&#x53E3;&#x521D;&#x63A2;</h1>
<p>&#x4E0B;&#x9762;&#x901A;&#x8FC7;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x793A;&#x4F8B;&#x6765;&#x89C2;&#x5BDF;&#x63A5;&#x53E3;&#x662F;&#x5982;&#x4F55;&#x5DE5;&#x4F5C;&#x7684;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">printLabel</span>(<span class="hljs-params">labelledObj: { label: <span class="hljs-built_in">string</span> }</span>) </span>{
  <span class="hljs-built_in">console</span>.log(labelledObj.label);
}

<span class="hljs-keyword">let</span> myObj = { size: <span class="hljs-number">10</span>, label: <span class="hljs-string">&quot;Size 10 Object&quot;</span> };
printLabel(myObj);
</code></pre>
<p>&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x5668;&#x4F1A;&#x67E5;&#x770B;<code>printLabel</code>&#x7684;&#x8C03;&#x7528;&#x3002;
<code>printLabel</code>&#x6709;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x5E76;&#x8981;&#x6C42;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x53C2;&#x6570;&#x6709;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;<code>label</code>&#x7C7B;&#x578B;&#x4E3A;<code>string</code>&#x7684;&#x5C5E;&#x6027;&#x3002;
&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x6211;&#x4EEC;&#x4F20;&#x5165;&#x7684;&#x5BF9;&#x8C61;&#x53C2;&#x6570;&#x5B9E;&#x9645;&#x4E0A;&#x4F1A;&#x5305;&#x542B;&#x5F88;&#x591A;&#x5C5E;&#x6027;&#xFF0C;&#x4F46;&#x662F;&#x7F16;&#x8BD1;&#x5668;&#x53EA;&#x4F1A;&#x68C0;&#x67E5;&#x90A3;&#x4E9B;&#x5FC5;&#x9700;&#x7684;&#x5C5E;&#x6027;&#x662F;&#x5426;&#x5B58;&#x5728;&#xFF0C;&#x5E76;&#x4E14;&#x5176;&#x7C7B;&#x578B;&#x662F;&#x5426;&#x5339;&#x914D;&#x3002;
&#x7136;&#x800C;&#xFF0C;&#x6709;&#x4E9B;&#x65F6;&#x5019;TypeScript&#x5374;&#x5E76;&#x4E0D;&#x4F1A;&#x8FD9;&#x4E48;&#x5BBD;&#x677E;&#xFF0C;&#x6211;&#x4EEC;&#x4E0B;&#x9762;&#x4F1A;&#x7A0D;&#x505A;&#x8BB2;&#x89E3;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x91CD;&#x5199;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#xFF0C;&#x8FD9;&#x6B21;&#x4F7F;&#x7528;&#x63A5;&#x53E3;&#x6765;&#x63CF;&#x8FF0;&#xFF1A;&#x5FC5;&#x987B;&#x5305;&#x542B;&#x4E00;&#x4E2A;<code>label</code>&#x5C5E;&#x6027;&#x4E14;&#x7C7B;&#x578B;&#x4E3A;<code>string</code>&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> LabelledValue {
  label: <span class="hljs-built_in">string</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">printLabel</span>(<span class="hljs-params">labelledObj: LabelledValue</span>) </span>{
  <span class="hljs-built_in">console</span>.log(labelledObj.label);
}

<span class="hljs-keyword">let</span> myObj = {size: <span class="hljs-number">10</span>, label: <span class="hljs-string">&quot;Size 10 Object&quot;</span>};
printLabel(myObj);
</code></pre>
<p><code>LabelledValue</code>&#x63A5;&#x53E3;&#x5C31;&#x597D;&#x6BD4;&#x4E00;&#x4E2A;&#x540D;&#x5B57;&#xFF0C;&#x7528;&#x6765;&#x63CF;&#x8FF0;&#x4E0A;&#x9762;&#x4F8B;&#x5B50;&#x91CC;&#x7684;&#x8981;&#x6C42;&#x3002;
&#x5B83;&#x4EE3;&#x8868;&#x4E86;&#x6709;&#x4E00;&#x4E2A;<code>label</code>&#x5C5E;&#x6027;&#x4E14;&#x7C7B;&#x578B;&#x4E3A;<code>string</code>&#x7684;&#x5BF9;&#x8C61;&#x3002;
&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x8FD9;&#x91CC;&#x5E76;&#x4E0D;&#x80FD;&#x50CF;&#x5728;&#x5176;&#x5B83;&#x8BED;&#x8A00;&#x91CC;&#x4E00;&#x6837;&#xFF0C;&#x8BF4;&#x4F20;&#x7ED9;<code>printLabel</code>&#x7684;&#x5BF9;&#x8C61;&#x5B9E;&#x73B0;&#x4E86;&#x8FD9;&#x4E2A;&#x63A5;&#x53E3;&#x3002;&#x6211;&#x4EEC;&#x53EA;&#x4F1A;&#x53BB;&#x5173;&#x6CE8;&#x503C;&#x7684;&#x5916;&#x5F62;&#x3002;
&#x53EA;&#x8981;&#x4F20;&#x5165;&#x7684;&#x5BF9;&#x8C61;&#x6EE1;&#x8DB3;&#x4E0A;&#x9762;&#x63D0;&#x5230;&#x7684;&#x5FC5;&#x8981;&#x6761;&#x4EF6;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x5C31;&#x662F;&#x88AB;&#x5141;&#x8BB8;&#x7684;&#x3002;</p>
<p>&#x8FD8;&#x6709;&#x4E00;&#x70B9;&#x503C;&#x5F97;&#x63D0;&#x7684;&#x662F;&#xFF0C;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x5668;&#x4E0D;&#x4F1A;&#x53BB;&#x68C0;&#x67E5;&#x5C5E;&#x6027;&#x7684;&#x987A;&#x5E8F;&#xFF0C;&#x53EA;&#x8981;&#x76F8;&#x5E94;&#x7684;&#x5C5E;&#x6027;&#x5B58;&#x5728;&#x5E76;&#x4E14;&#x7C7B;&#x578B;&#x4E5F;&#x662F;&#x5BF9;&#x7684;&#x5C31;&#x53EF;&#x4EE5;&#x3002;</p>
<h1 id="&#x53EF;&#x9009;&#x5C5E;&#x6027;">&#x53EF;&#x9009;&#x5C5E;&#x6027;</h1>
<p>&#x63A5;&#x53E3;&#x91CC;&#x7684;&#x5C5E;&#x6027;&#x4E0D;&#x5168;&#x90FD;&#x662F;&#x5FC5;&#x9700;&#x7684;&#x3002;
&#x6709;&#x4E9B;&#x662F;&#x53EA;&#x5728;&#x67D0;&#x4E9B;&#x6761;&#x4EF6;&#x4E0B;&#x5B58;&#x5728;&#xFF0C;&#x6216;&#x8005;&#x6839;&#x672C;&#x4E0D;&#x5B58;&#x5728;&#x3002;
&#x53EF;&#x9009;&#x5C5E;&#x6027;&#x5728;&#x5E94;&#x7528;&#x201C;option bags&#x201D;&#x6A21;&#x5F0F;&#x65F6;&#x5F88;&#x5E38;&#x7528;&#xFF0C;&#x5373;&#x7ED9;&#x51FD;&#x6570;&#x4F20;&#x5165;&#x7684;&#x53C2;&#x6570;&#x5BF9;&#x8C61;&#x4E2D;&#x53EA;&#x6709;&#x90E8;&#x5206;&#x5C5E;&#x6027;&#x8D4B;&#x503C;&#x4E86;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x662F;&#x5E94;&#x7528;&#x4E86;&#x201C;option bags&#x201D;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> SquareConfig {
  color?: <span class="hljs-built_in">string</span>;
  width?: <span class="hljs-built_in">number</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createSquare</span>(<span class="hljs-params">config: SquareConfig</span>): </span>{color: <span class="hljs-built_in">string</span>; area: <span class="hljs-built_in">number</span>} {
  <span class="hljs-keyword">let</span> newSquare = {color: <span class="hljs-string">&quot;white&quot;</span>, area: <span class="hljs-number">100</span>};
  <span class="hljs-keyword">if</span> (config.color) {
    newSquare.color = config.color;
  }
  <span class="hljs-keyword">if</span> (config.width) {
    newSquare.area = config.width * config.width;
  }
  <span class="hljs-keyword">return</span> newSquare;
}

<span class="hljs-keyword">let</span> mySquare = createSquare({color: <span class="hljs-string">&quot;black&quot;</span>});
</code></pre>
<p>&#x5E26;&#x6709;&#x53EF;&#x9009;&#x5C5E;&#x6027;&#x7684;&#x63A5;&#x53E3;&#x4E0E;&#x666E;&#x901A;&#x7684;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;&#x5DEE;&#x4E0D;&#x591A;&#xFF0C;&#x53EA;&#x662F;&#x5728;&#x53EF;&#x9009;&#x5C5E;&#x6027;&#x540D;&#x5B57;&#x5B9A;&#x4E49;&#x7684;&#x540E;&#x9762;&#x52A0;&#x4E00;&#x4E2A;<code>?</code>&#x7B26;&#x53F7;&#x3002;</p>
<p>&#x53EF;&#x9009;&#x5C5E;&#x6027;&#x7684;&#x597D;&#x5904;&#x4E4B;&#x4E00;&#x662F;&#x53EF;&#x4EE5;&#x5BF9;&#x53EF;&#x80FD;&#x5B58;&#x5728;&#x7684;&#x5C5E;&#x6027;&#x8FDB;&#x884C;&#x9884;&#x5B9A;&#x4E49;&#xFF0C;&#x597D;&#x5904;&#x4E4B;&#x4E8C;&#x662F;&#x53EF;&#x4EE5;&#x6355;&#x83B7;&#x5F15;&#x7528;&#x4E86;&#x4E0D;&#x5B58;&#x5728;&#x7684;&#x5C5E;&#x6027;&#x65F6;&#x7684;&#x9519;&#x8BEF;&#x3002;
&#x6BD4;&#x5982;&#xFF0C;&#x6211;&#x4EEC;&#x6545;&#x610F;&#x5C06;<code>createSquare</code>&#x91CC;&#x7684;<code>color</code>&#x5C5E;&#x6027;&#x540D;&#x62FC;&#x9519;&#xFF0C;&#x5C31;&#x4F1A;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;&#x63D0;&#x793A;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> SquareConfig {
  color?: <span class="hljs-built_in">string</span>;
  width?: <span class="hljs-built_in">number</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createSquare</span>(<span class="hljs-params">config: SquareConfig</span>): </span>{ color: <span class="hljs-built_in">string</span>; area: <span class="hljs-built_in">number</span> } {
  <span class="hljs-keyword">let</span> newSquare = {color: <span class="hljs-string">&quot;white&quot;</span>, area: <span class="hljs-number">100</span>};
  <span class="hljs-keyword">if</span> (config.clor) {
    <span class="hljs-comment">// Error: Property &apos;clor&apos; does not exist on type &apos;SquareConfig&apos;</span>
    newSquare.color = config.clor;
  }
  <span class="hljs-keyword">if</span> (config.width) {
    newSquare.area = config.width * config.width;
  }
  <span class="hljs-keyword">return</span> newSquare;
}

<span class="hljs-keyword">let</span> mySquare = createSquare({color: <span class="hljs-string">&quot;black&quot;</span>});
</code></pre>
<h1 id="&#x53EA;&#x8BFB;&#x5C5E;&#x6027;">&#x53EA;&#x8BFB;&#x5C5E;&#x6027;</h1>
<p>&#x4E00;&#x4E9B;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x53EA;&#x80FD;&#x5728;&#x5BF9;&#x8C61;&#x521A;&#x521A;&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x5019;&#x4FEE;&#x6539;&#x5176;&#x503C;&#x3002;
&#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x5C5E;&#x6027;&#x540D;&#x524D;&#x7528;<code>readonly</code>&#x6765;&#x6307;&#x5B9A;&#x53EA;&#x8BFB;&#x5C5E;&#x6027;:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> Point {
    readonly x: <span class="hljs-built_in">number</span>;
    readonly y: <span class="hljs-built_in">number</span>;
}
</code></pre>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8D4B;&#x503C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x5B57;&#x9762;&#x91CF;&#x6765;&#x6784;&#x9020;&#x4E00;&#x4E2A;<code>Point</code>&#x3002;
&#x8D4B;&#x503C;&#x540E;&#xFF0C;<code>x</code>&#x548C;<code>y</code>&#x518D;&#x4E5F;&#x4E0D;&#x80FD;&#x88AB;&#x6539;&#x53D8;&#x4E86;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> p1: Point = { x: <span class="hljs-number">10</span>, y: <span class="hljs-number">20</span> };
p1.x = <span class="hljs-number">5</span>; <span class="hljs-comment">// error!</span>
</code></pre>
<p>TypeScript&#x5177;&#x6709;<code>ReadonlyArray&lt;T&gt;</code>&#x7C7B;&#x578B;&#xFF0C;&#x5B83;&#x4E0E;<code>Array&lt;T&gt;</code>&#x76F8;&#x4F3C;&#xFF0C;&#x53EA;&#x662F;&#x628A;&#x6240;&#x6709;&#x53EF;&#x53D8;&#x65B9;&#x6CD5;&#x53BB;&#x6389;&#x4E86;&#xFF0C;&#x56E0;&#x6B64;&#x53EF;&#x4EE5;&#x786E;&#x4FDD;&#x6570;&#x7EC4;&#x521B;&#x5EFA;&#x540E;&#x518D;&#x4E5F;&#x4E0D;&#x80FD;&#x88AB;&#x4FEE;&#x6539;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> a: <span class="hljs-built_in">number</span>[] = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>];
<span class="hljs-keyword">let</span> ro: ReadonlyArray&lt;<span class="hljs-built_in">number</span>&gt; = a;
ro[<span class="hljs-number">0</span>] = <span class="hljs-number">12</span>; <span class="hljs-comment">// error!</span>
ro.push(<span class="hljs-number">5</span>); <span class="hljs-comment">// error!</span>
ro.length = <span class="hljs-number">100</span>; <span class="hljs-comment">// error!</span>
a = ro; <span class="hljs-comment">// error!</span>
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x7684;&#x6700;&#x540E;&#x4E00;&#x884C;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x5C31;&#x7B97;&#x628A;&#x6574;&#x4E2A;<code>ReadonlyArray</code>&#x8D4B;&#x503C;&#x5230;&#x4E00;&#x4E2A;&#x666E;&#x901A;&#x6570;&#x7EC4;&#x4E5F;&#x662F;&#x4E0D;&#x53EF;&#x4EE5;&#x7684;&#x3002;
&#x4F46;&#x662F;&#x4F60;&#x53EF;&#x4EE5;&#x7528;&#x7C7B;&#x578B;&#x65AD;&#x8A00;&#x91CD;&#x5199;&#xFF1A;</p>
<pre><code class="lang-ts">a = ro as <span class="hljs-built_in">number</span>[];
</code></pre>
<h2 id="readonly-vs-const"><code>readonly</code> vs <code>const</code></h2>
<p>&#x6700;&#x7B80;&#x5355;&#x5224;&#x65AD;&#x8BE5;&#x7528;<code>readonly</code>&#x8FD8;&#x662F;<code>const</code>&#x7684;&#x65B9;&#x6CD5;&#x662F;&#x770B;&#x8981;&#x628A;&#x5B83;&#x505A;&#x4E3A;&#x53D8;&#x91CF;&#x4F7F;&#x7528;&#x8FD8;&#x662F;&#x505A;&#x4E3A;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x3002;
&#x505A;&#x4E3A;&#x53D8;&#x91CF;&#x4F7F;&#x7528;&#x7684;&#x8BDD;&#x7528;<code>const</code>&#xFF0C;&#x82E5;&#x505A;&#x4E3A;&#x5C5E;&#x6027;&#x5219;&#x4F7F;&#x7528;<code>readonly</code>&#x3002;</p>
<h1 id="&#x989D;&#x5916;&#x7684;&#x5C5E;&#x6027;&#x68C0;&#x67E5;">&#x989D;&#x5916;&#x7684;&#x5C5E;&#x6027;&#x68C0;&#x67E5;</h1>
<p>&#x6211;&#x4EEC;&#x5728;&#x7B2C;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x91CC;&#x4F7F;&#x7528;&#x4E86;&#x63A5;&#x53E3;&#xFF0C;TypeScript&#x8BA9;&#x6211;&#x4EEC;&#x4F20;&#x5165;<code>{ size: number; label: string; }</code>&#x5230;&#x4EC5;&#x671F;&#x671B;&#x5F97;&#x5230;<code>{ label: string; }</code>&#x7684;&#x51FD;&#x6570;&#x91CC;&#x3002;
&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5B66;&#x8FC7;&#x4E86;&#x53EF;&#x9009;&#x5C5E;&#x6027;&#xFF0C;&#x5E76;&#x4E14;&#x77E5;&#x9053;&#x4ED6;&#x4EEC;&#x5728;&#x201C;option bags&#x201D;&#x6A21;&#x5F0F;&#x91CC;&#x5F88;&#x6709;&#x7528;&#x3002;</p>
<p>&#x7136;&#x800C;&#xFF0C;&#x5929;&#x771F;&#x5730;&#x5C06;&#x8FD9;&#x4E24;&#x8005;&#x7ED3;&#x5408;&#x7684;&#x8BDD;&#x5C31;&#x4F1A;&#x50CF;&#x5728;JavaScript&#x91CC;&#x90A3;&#x6837;&#x642C;&#x8D77;&#x77F3;&#x5934;&#x7838;&#x81EA;&#x5DF1;&#x7684;&#x811A;&#x3002;
&#x6BD4;&#x5982;&#xFF0C;&#x62FF;<code>createSquare</code>&#x4F8B;&#x5B50;&#x6765;&#x8BF4;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> SquareConfig {
    color?: <span class="hljs-built_in">string</span>;
    width?: <span class="hljs-built_in">number</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createSquare</span>(<span class="hljs-params">config: SquareConfig</span>): </span>{ color: <span class="hljs-built_in">string</span>; area: <span class="hljs-built_in">number</span> } {
    <span class="hljs-comment">// ...</span>
}

<span class="hljs-keyword">let</span> mySquare = createSquare({ colour: <span class="hljs-string">&quot;red&quot;</span>, width: <span class="hljs-number">100</span> });
</code></pre>
<p>&#x6CE8;&#x610F;&#x4F20;&#x5165;<code>createSquare</code>&#x7684;&#x53C2;&#x6570;&#x62FC;&#x5199;&#x4E3A;<code>colour</code>&#x800C;&#x4E0D;&#x662F;<code>color</code>&#x3002;
&#x5728;JavaScript&#x91CC;&#xFF0C;&#x8FD9;&#x4F1A;&#x9ED8;&#x9ED8;&#x5730;&#x5931;&#x8D25;&#x3002;</p>
<p>&#x4F60;&#x53EF;&#x80FD;&#x4F1A;&#x4E89;&#x8FA9;&#x8FD9;&#x4E2A;&#x7A0B;&#x5E8F;&#x5DF2;&#x7ECF;&#x6B63;&#x786E;&#x5730;&#x7C7B;&#x578B;&#x5316;&#x4E86;&#xFF0C;&#x56E0;&#x4E3A;<code>width</code>&#x5C5E;&#x6027;&#x662F;&#x517C;&#x5BB9;&#x7684;&#xFF0C;&#x4E0D;&#x5B58;&#x5728;<code>color</code>&#x5C5E;&#x6027;&#xFF0C;&#x800C;&#x4E14;&#x989D;&#x5916;&#x7684;<code>colour</code>&#x5C5E;&#x6027;&#x662F;&#x65E0;&#x610F;&#x4E49;&#x7684;&#x3002;</p>
<p>&#x7136;&#x800C;&#xFF0C;TypeScript&#x4F1A;&#x8BA4;&#x4E3A;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x53EF;&#x80FD;&#x5B58;&#x5728;bug&#x3002;
&#x5BF9;&#x8C61;&#x5B57;&#x9762;&#x91CF;&#x4F1A;&#x88AB;&#x7279;&#x6B8A;&#x5BF9;&#x5F85;&#x800C;&#x4E14;&#x4F1A;&#x7ECF;&#x8FC7;<em>&#x989D;&#x5916;&#x5C5E;&#x6027;&#x68C0;&#x67E5;</em>&#xFF0C;&#x5F53;&#x5C06;&#x5B83;&#x4EEC;&#x8D4B;&#x503C;&#x7ED9;&#x53D8;&#x91CF;&#x6216;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x7684;&#x65F6;&#x5019;&#x3002;
&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x5B57;&#x9762;&#x91CF;&#x5B58;&#x5728;&#x4EFB;&#x4F55;&#x201C;&#x76EE;&#x6807;&#x7C7B;&#x578B;&#x201D;&#x4E0D;&#x5305;&#x542B;&#x7684;&#x5C5E;&#x6027;&#x65F6;&#xFF0C;&#x4F60;&#x4F1A;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-comment">// error: &apos;colour&apos; not expected in type &apos;SquareConfig&apos;</span>
<span class="hljs-keyword">let</span> mySquare = createSquare({ colour: <span class="hljs-string">&quot;red&quot;</span>, width: <span class="hljs-number">100</span> });
</code></pre>
<p>&#x7ED5;&#x5F00;&#x8FD9;&#x4E9B;&#x68C0;&#x67E5;&#x975E;&#x5E38;&#x7B80;&#x5355;&#x3002;
&#x6700;&#x7B80;&#x4FBF;&#x7684;&#x65B9;&#x6CD5;&#x662F;&#x4F7F;&#x7528;&#x7C7B;&#x578B;&#x65AD;&#x8A00;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> mySquare = createSquare({ width: <span class="hljs-number">100</span>, opacity: <span class="hljs-number">0.5</span> } as SquareConfig);
</code></pre>
<p>&#x7136;&#x800C;&#xFF0C;&#x6700;&#x4F73;&#x7684;&#x65B9;&#x5F0F;&#x662F;&#x80FD;&#x591F;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#xFF0C;&#x524D;&#x63D0;&#x662F;&#x4F60;&#x80FD;&#x591F;&#x786E;&#x5B9A;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x53EF;&#x80FD;&#x5177;&#x6709;&#x67D0;&#x4E9B;&#x505A;&#x4E3A;&#x7279;&#x6B8A;&#x7528;&#x9014;&#x4F7F;&#x7528;&#x7684;&#x989D;&#x5916;&#x5C5E;&#x6027;&#x3002;
&#x5982;&#x679C;<code>SquareConfig</code>&#x5E26;&#x6709;&#x4E0A;&#x9762;&#x5B9A;&#x4E49;&#x7684;&#x7C7B;&#x578B;&#x7684;<code>color</code>&#x548C;<code>width</code>&#x5C5E;&#x6027;&#xFF0C;&#x5E76;&#x4E14;<em>&#x8FD8;&#x4F1A;</em>&#x5E26;&#x6709;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x5176;&#x5B83;&#x5C5E;&#x6027;&#xFF0C;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x5B9A;&#x4E49;&#x5B83;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> SquareConfig {
    color?: <span class="hljs-built_in">string</span>;
    width?: <span class="hljs-built_in">number</span>;
    [propName: <span class="hljs-built_in">string</span>]: <span class="hljs-built_in">any</span>;
}
</code></pre>
<p>&#x6211;&#x4EEC;&#x7A0D;&#x540E;&#x4F1A;&#x8BB2;&#x5230;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#xFF0C;&#x4F46;&#x5728;&#x8FD9;&#x6211;&#x4EEC;&#x8981;&#x8868;&#x793A;&#x7684;&#x662F;<code>SquareConfig</code>&#x53EF;&#x4EE5;&#x6709;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x5E76;&#x4E14;&#x53EA;&#x8981;&#x5B83;&#x4EEC;&#x4E0D;&#x662F;<code>color</code>&#x548C;<code>width</code>&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x65E0;&#x6240;&#x8C13;&#x5B83;&#x4EEC;&#x7684;&#x7C7B;&#x578B;&#x662F;&#x4EC0;&#x4E48;&#x3002;</p>
<p>&#x8FD8;&#x6709;&#x6700;&#x540E;&#x4E00;&#x79CD;&#x8DF3;&#x8FC7;&#x8FD9;&#x4E9B;&#x68C0;&#x67E5;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x8FD9;&#x53EF;&#x80FD;&#x4F1A;&#x8BA9;&#x4F60;&#x611F;&#x5230;&#x60CA;&#x8BB6;&#xFF0C;&#x5B83;&#x5C31;&#x662F;&#x5C06;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x8D4B;&#x503C;&#x7ED9;&#x4E00;&#x4E2A;&#x53E6;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#xFF1A;
&#x56E0;&#x4E3A;<code>squareOptions</code>&#x4E0D;&#x4F1A;&#x7ECF;&#x8FC7;&#x989D;&#x5916;&#x5C5E;&#x6027;&#x68C0;&#x67E5;&#xFF0C;&#x6240;&#x4EE5;&#x7F16;&#x8BD1;&#x5668;&#x4E0D;&#x4F1A;&#x62A5;&#x9519;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> squareOptions = { colour: <span class="hljs-string">&quot;red&quot;</span>, width: <span class="hljs-number">100</span> };
<span class="hljs-keyword">let</span> mySquare = createSquare(squareOptions);
</code></pre>
<p>&#x8981;&#x7559;&#x610F;&#xFF0C;&#x5728;&#x50CF;&#x4E0A;&#x9762;&#x4E00;&#x6837;&#x7684;&#x7B80;&#x5355;&#x4EE3;&#x7801;&#x91CC;&#xFF0C;&#x4F60;&#x53EF;&#x80FD;&#x4E0D;&#x5E94;&#x8BE5;&#x53BB;&#x7ED5;&#x5F00;&#x8FD9;&#x4E9B;&#x68C0;&#x67E5;&#x3002;
&#x5BF9;&#x4E8E;&#x5305;&#x542B;&#x65B9;&#x6CD5;&#x548C;&#x5185;&#x90E8;&#x72B6;&#x6001;&#x7684;&#x590D;&#x6742;&#x5BF9;&#x8C61;&#x5B57;&#x9762;&#x91CF;&#x6765;&#x8BB2;&#xFF0C;&#x4F60;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x8FD9;&#x4E9B;&#x6280;&#x5DE7;&#xFF0C;&#x4F46;&#x662F;&#x5927;&#x90E8;&#x989D;&#x5916;&#x5C5E;&#x6027;&#x68C0;&#x67E5;&#x9519;&#x8BEF;&#x662F;&#x771F;&#x6B63;&#x7684;bug&#x3002;
&#x5C31;&#x662F;&#x8BF4;&#x4F60;&#x9047;&#x5230;&#x4E86;&#x989D;&#x5916;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x51FA;&#x7684;&#x9519;&#x8BEF;&#xFF0C;&#x6BD4;&#x5982;&#x201C;option bags&#x201D;&#xFF0C;&#x4F60;&#x5E94;&#x8BE5;&#x53BB;&#x5BA1;&#x67E5;&#x4E00;&#x4E0B;&#x4F60;&#x7684;&#x7C7B;&#x578B;&#x58F0;&#x660E;&#x3002;
&#x5728;&#x8FD9;&#x91CC;&#xFF0C;&#x5982;&#x679C;&#x652F;&#x6301;&#x4F20;&#x5165;<code>color</code>&#x6216;<code>colour</code>&#x5C5E;&#x6027;&#x5230;<code>createSquare</code>&#xFF0C;&#x4F60;&#x5E94;&#x8BE5;&#x4FEE;&#x6539;<code>SquareConfig</code>&#x5B9A;&#x4E49;&#x6765;&#x4F53;&#x73B0;&#x51FA;&#x8FD9;&#x4E00;&#x70B9;&#x3002;</p>
<h1 id="&#x51FD;&#x6570;&#x7C7B;&#x578B;">&#x51FD;&#x6570;&#x7C7B;&#x578B;</h1>
<p>&#x63A5;&#x53E3;&#x80FD;&#x591F;&#x63CF;&#x8FF0;JavaScript&#x4E2D;&#x5BF9;&#x8C61;&#x62E5;&#x6709;&#x7684;&#x5404;&#x79CD;&#x5404;&#x6837;&#x7684;&#x5916;&#x5F62;&#x3002;
&#x9664;&#x4E86;&#x63CF;&#x8FF0;&#x5E26;&#x6709;&#x5C5E;&#x6027;&#x7684;&#x666E;&#x901A;&#x5BF9;&#x8C61;&#x5916;&#xFF0C;&#x63A5;&#x53E3;&#x4E5F;&#x53EF;&#x4EE5;&#x63CF;&#x8FF0;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x3002;</p>
<p>&#x4E3A;&#x4E86;&#x4F7F;&#x7528;&#x63A5;&#x53E3;&#x8868;&#x793A;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7ED9;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x8C03;&#x7528;&#x7B7E;&#x540D;&#x3002;
&#x5B83;&#x5C31;&#x50CF;&#x662F;&#x4E00;&#x4E2A;&#x53EA;&#x6709;&#x53C2;&#x6570;&#x5217;&#x8868;&#x548C;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x7684;&#x51FD;&#x6570;&#x5B9A;&#x4E49;&#x3002;&#x53C2;&#x6570;&#x5217;&#x8868;&#x91CC;&#x7684;&#x6BCF;&#x4E2A;&#x53C2;&#x6570;&#x90FD;&#x9700;&#x8981;&#x540D;&#x5B57;&#x548C;&#x7C7B;&#x578B;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> SearchFunc {
  (source: <span class="hljs-built_in">string</span>, subString: <span class="hljs-built_in">string</span>): <span class="hljs-built_in">boolean</span>;
}
</code></pre>
<p>&#x8FD9;&#x6837;&#x5B9A;&#x4E49;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x50CF;&#x4F7F;&#x7528;&#x5176;&#x5B83;&#x63A5;&#x53E3;&#x4E00;&#x6837;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x7684;&#x63A5;&#x53E3;&#x3002;
&#x4E0B;&#x4F8B;&#x5C55;&#x793A;&#x4E86;&#x5982;&#x4F55;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5E76;&#x5C06;&#x4E00;&#x4E2A;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x51FD;&#x6570;&#x8D4B;&#x503C;&#x7ED9;&#x8FD9;&#x4E2A;&#x53D8;&#x91CF;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> mySearch: SearchFunc;
mySearch = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">source: <span class="hljs-built_in">string</span>, subString: <span class="hljs-built_in">string</span></span>) </span>{
  <span class="hljs-keyword">let</span> result = source.search(subString);
  <span class="hljs-keyword">return</span> result &gt; <span class="hljs-number">-1</span>;
}
</code></pre>
<p>&#x5BF9;&#x4E8E;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x7684;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x6765;&#x8BF4;&#xFF0C;&#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570;&#x540D;&#x4E0D;&#x9700;&#x8981;&#x4E0E;&#x63A5;&#x53E3;&#x91CC;&#x5B9A;&#x4E49;&#x7684;&#x540D;&#x5B57;&#x76F8;&#x5339;&#x914D;&#x3002;
&#x6BD4;&#x5982;&#xFF0C;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x4E0B;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x91CD;&#x5199;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> mySearch: SearchFunc;
mySearch = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">src: <span class="hljs-built_in">string</span>, sub: <span class="hljs-built_in">string</span></span>): <span class="hljs-title">boolean</span> </span>{
  <span class="hljs-keyword">let</span> result = src.search(sub);
  <span class="hljs-keyword">return</span> result &gt; <span class="hljs-number">-1</span>;
}
</code></pre>
<p>&#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570;&#x4F1A;&#x9010;&#x4E2A;&#x8FDB;&#x884C;&#x68C0;&#x67E5;&#xFF0C;&#x8981;&#x6C42;&#x5BF9;&#x5E94;&#x4F4D;&#x7F6E;&#x4E0A;&#x7684;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x662F;&#x517C;&#x5BB9;&#x7684;&#x3002;
&#x5982;&#x679C;&#x4F60;&#x4E0D;&#x60F3;&#x6307;&#x5B9A;&#x7C7B;&#x578B;&#xFF0C;TypeScript&#x7684;&#x7C7B;&#x578B;&#x7CFB;&#x7EDF;&#x4F1A;&#x63A8;&#x65AD;&#x51FA;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#xFF0C;&#x56E0;&#x4E3A;&#x51FD;&#x6570;&#x76F4;&#x63A5;&#x8D4B;&#x503C;&#x7ED9;&#x4E86;<code>SearchFunc</code>&#x7C7B;&#x578B;&#x53D8;&#x91CF;&#x3002;
&#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x662F;&#x901A;&#x8FC7;&#x5176;&#x8FD4;&#x56DE;&#x503C;&#x63A8;&#x65AD;&#x51FA;&#x6765;&#x7684;&#xFF08;&#x6B64;&#x4F8B;&#x662F;<code>false</code>&#x548C;<code>true</code>&#xFF09;&#x3002;
&#x5982;&#x679C;&#x8BA9;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x6570;&#x5B57;&#x6216;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x5668;&#x4F1A;&#x8B66;&#x544A;&#x6211;&#x4EEC;&#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E0E;<code>SearchFunc</code>&#x63A5;&#x53E3;&#x4E2D;&#x7684;&#x5B9A;&#x4E49;&#x4E0D;&#x5339;&#x914D;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> mySearch: SearchFunc;
mySearch = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">src, sub</span>) </span>{
    <span class="hljs-keyword">let</span> result = src.search(sub);
    <span class="hljs-keyword">return</span> result &gt; <span class="hljs-number">-1</span>;
}
</code></pre>
<h1 id="&#x53EF;&#x7D22;&#x5F15;&#x7684;&#x7C7B;&#x578B;">&#x53EF;&#x7D22;&#x5F15;&#x7684;&#x7C7B;&#x578B;</h1>
<p>&#x4E0E;&#x4F7F;&#x7528;&#x63A5;&#x53E3;&#x63CF;&#x8FF0;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x5DEE;&#x4E0D;&#x591A;&#xFF0C;&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x63CF;&#x8FF0;&#x90A3;&#x4E9B;&#x80FD;&#x591F;&#x201C;&#x901A;&#x8FC7;&#x7D22;&#x5F15;&#x5F97;&#x5230;&#x201D;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x6BD4;&#x5982;<code>a[10]</code>&#x6216;<code>ageMap[&quot;daniel&quot;]</code>&#x3002;
&#x53EF;&#x7D22;&#x5F15;&#x7C7B;&#x578B;&#x5177;&#x6709;&#x4E00;&#x4E2A;<em>&#x7D22;&#x5F15;&#x7B7E;&#x540D;</em>&#xFF0C;&#x5B83;&#x63CF;&#x8FF0;&#x4E86;&#x5BF9;&#x8C61;&#x7D22;&#x5F15;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x8FD8;&#x6709;&#x76F8;&#x5E94;&#x7684;&#x7D22;&#x5F15;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x3002;
&#x8BA9;&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> StringArray {
  [index: <span class="hljs-built_in">number</span>]: <span class="hljs-built_in">string</span>;
}

<span class="hljs-keyword">let</span> myArray: StringArray;
myArray = [<span class="hljs-string">&quot;Bob&quot;</span>, <span class="hljs-string">&quot;Fred&quot;</span>];

<span class="hljs-keyword">let</span> myStr: <span class="hljs-built_in">string</span> = myArray[<span class="hljs-number">0</span>];
</code></pre>
<p>&#x4E0A;&#x9762;&#x4F8B;&#x5B50;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x5B9A;&#x4E49;&#x4E86;<code>StringArray</code>&#x63A5;&#x53E3;&#xFF0C;&#x5B83;&#x5177;&#x6709;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x3002;
&#x8FD9;&#x4E2A;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x8868;&#x793A;&#x4E86;&#x5F53;&#x7528;<code>number</code>&#x53BB;&#x7D22;&#x5F15;<code>StringArray</code>&#x65F6;&#x4F1A;&#x5F97;&#x5230;<code>string</code>&#x7C7B;&#x578B;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x3002;</p>
<p>Typescript&#x652F;&#x6301;&#x4E24;&#x79CD;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#xFF1A;&#x5B57;&#x7B26;&#x4E32;&#x548C;&#x6570;&#x5B57;&#x3002;
&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x4F7F;&#x7528;&#x4E24;&#x79CD;&#x7C7B;&#x578B;&#x7684;&#x7D22;&#x5F15;&#xFF0C;&#x4F46;&#x662F;&#x6570;&#x5B57;&#x7D22;&#x5F15;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x5FC5;&#x987B;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x7684;&#x5B50;&#x7C7B;&#x578B;&#x3002;
&#x8FD9;&#x662F;&#x56E0;&#x4E3A;&#x5F53;&#x4F7F;&#x7528;<code>number</code>&#x6765;&#x7D22;&#x5F15;&#x65F6;&#xFF0C;JavaScript&#x4F1A;&#x5C06;&#x5B83;&#x8F6C;&#x6362;&#x6210;<code>string</code>&#x7136;&#x540E;&#x518D;&#x53BB;&#x7D22;&#x5F15;&#x5BF9;&#x8C61;&#x3002;
&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x7528;<code>100</code>&#xFF08;&#x4E00;&#x4E2A;<code>number</code>&#xFF09;&#x53BB;&#x7D22;&#x5F15;&#x7B49;&#x540C;&#x4E8E;&#x4F7F;&#x7528;<code>&quot;100&quot;</code>&#xFF08;&#x4E00;&#x4E2A;<code>string</code>&#xFF09;&#x53BB;&#x7D22;&#x5F15;&#xFF0C;&#x56E0;&#x6B64;&#x4E24;&#x8005;&#x9700;&#x8981;&#x4FDD;&#x6301;&#x4E00;&#x81F4;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Animal {
    name: <span class="hljs-built_in">string</span>;
}
<span class="hljs-keyword">class</span> Dog extends Animal {
    breed: <span class="hljs-built_in">string</span>;
}

<span class="hljs-comment">// &#x9519;&#x8BEF;&#xFF1A;&#x4F7F;&#x7528;&#x6570;&#x503C;&#x578B;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#xFF0C;&#x6709;&#x65F6;&#x4F1A;&#x5F97;&#x5230;&#x5B8C;&#x5168;&#x4E0D;&#x540C;&#x7684;Animal!</span>
<span class="hljs-keyword">interface</span> NotOkay {
    [x: <span class="hljs-built_in">number</span>]: Animal;
    [x: <span class="hljs-built_in">string</span>]: Dog;
}
</code></pre>
<p>&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x80FD;&#x591F;&#x5F88;&#x597D;&#x7684;&#x63CF;&#x8FF0;<code>dictionary</code>&#x6A21;&#x5F0F;&#xFF0C;&#x5E76;&#x4E14;&#x5B83;&#x4EEC;&#x4E5F;&#x4F1A;&#x786E;&#x4FDD;&#x6240;&#x6709;&#x5C5E;&#x6027;&#x4E0E;&#x5176;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x76F8;&#x5339;&#x914D;&#x3002;
&#x56E0;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x58F0;&#x660E;&#x4E86;<code>obj.property</code>&#x548C;<code>obj[&quot;property&quot;]</code>&#x4E24;&#x79CD;&#x5F62;&#x5F0F;&#x90FD;&#x53EF;&#x4EE5;&#x3002;
&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x91CC;&#xFF0C;<code>name</code>&#x7684;&#x7C7B;&#x578B;&#x4E0E;&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x7C7B;&#x578B;&#x4E0D;&#x5339;&#x914D;&#xFF0C;&#x6240;&#x4EE5;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x5668;&#x7ED9;&#x51FA;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;&#x63D0;&#x793A;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> NumberDictionary {
  [index: <span class="hljs-built_in">string</span>]: <span class="hljs-built_in">number</span>;
  length: <span class="hljs-built_in">number</span>;    <span class="hljs-comment">// &#x53EF;&#x4EE5;&#xFF0C;length&#x662F;number&#x7C7B;&#x578B;</span>
  name: <span class="hljs-built_in">string</span>       <span class="hljs-comment">// &#x9519;&#x8BEF;&#xFF0C;`name`&#x7684;&#x7C7B;&#x578B;&#x4E0E;&#x7D22;&#x5F15;&#x7C7B;&#x578B;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x7C7B;&#x578B;&#x4E0D;&#x5339;&#x914D;</span>
}
</code></pre>
<p>&#x6700;&#x540E;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5C06;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x8BBE;&#x7F6E;&#x4E3A;&#x53EA;&#x8BFB;&#xFF0C;&#x8FD9;&#x6837;&#x5C31;&#x9632;&#x6B62;&#x4E86;&#x7ED9;&#x7D22;&#x5F15;&#x8D4B;&#x503C;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> ReadonlyStringArray {
    readonly [index: <span class="hljs-built_in">number</span>]: <span class="hljs-built_in">string</span>;
}
<span class="hljs-keyword">let</span> myArray: ReadonlyStringArray = [<span class="hljs-string">&quot;Alice&quot;</span>, <span class="hljs-string">&quot;Bob&quot;</span>];
myArray[<span class="hljs-number">2</span>] = <span class="hljs-string">&quot;Mallory&quot;</span>; <span class="hljs-comment">// error!</span>
</code></pre>
<p>&#x4F60;&#x4E0D;&#x80FD;&#x8BBE;&#x7F6E;<code>myArray[2]</code>&#xFF0C;&#x56E0;&#x4E3A;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x662F;&#x53EA;&#x8BFB;&#x7684;&#x3002;</p>
<h1 id="&#x7C7B;&#x7C7B;&#x578B;">&#x7C7B;&#x7C7B;&#x578B;</h1>
<h2 id="&#x5B9E;&#x73B0;&#x63A5;&#x53E3;">&#x5B9E;&#x73B0;&#x63A5;&#x53E3;</h2>
<p>&#x4E0E;C#&#x6216;Java&#x91CC;&#x63A5;&#x53E3;&#x7684;&#x57FA;&#x672C;&#x4F5C;&#x7528;&#x4E00;&#x6837;&#xFF0C;TypeScript&#x4E5F;&#x80FD;&#x591F;&#x7528;&#x5B83;&#x6765;&#x660E;&#x786E;&#x7684;&#x5F3A;&#x5236;&#x4E00;&#x4E2A;&#x7C7B;&#x53BB;&#x7B26;&#x5408;&#x67D0;&#x79CD;&#x5951;&#x7EA6;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> ClockInterface {
    currentTime: <span class="hljs-built_in">Date</span>;
}

<span class="hljs-keyword">class</span> Clock <span class="hljs-keyword">implements</span> ClockInterface {
    currentTime: <span class="hljs-built_in">Date</span>;
    <span class="hljs-keyword">constructor</span>(h: number, m: number) { }
}
</code></pre>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x5728;&#x63A5;&#x53E3;&#x4E2D;&#x63CF;&#x8FF0;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x5728;&#x7C7B;&#x91CC;&#x5B9E;&#x73B0;&#x5B83;&#xFF0C;&#x5982;&#x540C;&#x4E0B;&#x9762;&#x7684;<code>setTime</code>&#x65B9;&#x6CD5;&#x4E00;&#x6837;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> ClockInterface {
    currentTime: <span class="hljs-built_in">Date</span>;
    setTime(d: <span class="hljs-built_in">Date</span>);
}

<span class="hljs-keyword">class</span> Clock <span class="hljs-keyword">implements</span> ClockInterface {
    currentTime: <span class="hljs-built_in">Date</span>;
    setTime(d: <span class="hljs-built_in">Date</span>) {
        <span class="hljs-keyword">this</span>.currentTime = d;
    }
    <span class="hljs-keyword">constructor</span>(h: number, m: number) { }
}
</code></pre>
<p>&#x63A5;&#x53E3;&#x63CF;&#x8FF0;&#x4E86;&#x7C7B;&#x7684;&#x516C;&#x5171;&#x90E8;&#x5206;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x516C;&#x5171;&#x548C;&#x79C1;&#x6709;&#x4E24;&#x90E8;&#x5206;&#x3002;
&#x5B83;&#x4E0D;&#x4F1A;&#x5E2E;&#x4F60;&#x68C0;&#x67E5;&#x7C7B;&#x662F;&#x5426;&#x5177;&#x6709;&#x67D0;&#x4E9B;&#x79C1;&#x6709;&#x6210;&#x5458;&#x3002;</p>
<h2 id="&#x7C7B;&#x9759;&#x6001;&#x90E8;&#x5206;&#x4E0E;&#x5B9E;&#x4F8B;&#x90E8;&#x5206;&#x7684;&#x533A;&#x522B;">&#x7C7B;&#x9759;&#x6001;&#x90E8;&#x5206;&#x4E0E;&#x5B9E;&#x4F8B;&#x90E8;&#x5206;&#x7684;&#x533A;&#x522B;</h2>
<p>&#x5F53;&#x4F60;&#x64CD;&#x4F5C;&#x7C7B;&#x548C;&#x63A5;&#x53E3;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F60;&#x8981;&#x77E5;&#x9053;&#x7C7B;&#x662F;&#x5177;&#x6709;&#x4E24;&#x4E2A;&#x7C7B;&#x578B;&#x7684;&#xFF1A;&#x9759;&#x6001;&#x90E8;&#x5206;&#x7684;&#x7C7B;&#x578B;&#x548C;&#x5B9E;&#x4F8B;&#x7684;&#x7C7B;&#x578B;&#x3002;
&#x4F60;&#x4F1A;&#x6CE8;&#x610F;&#x5230;&#xFF0C;&#x5F53;&#x4F60;&#x7528;&#x6784;&#x9020;&#x5668;&#x7B7E;&#x540D;&#x53BB;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#x5E76;&#x8BD5;&#x56FE;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7C7B;&#x53BB;&#x5B9E;&#x73B0;&#x8FD9;&#x4E2A;&#x63A5;&#x53E3;&#x65F6;&#x4F1A;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> ClockConstructor {
    <span class="hljs-keyword">new</span> (hour: <span class="hljs-built_in">number</span>, minute: <span class="hljs-built_in">number</span>);
}

<span class="hljs-keyword">class</span> Clock <span class="hljs-keyword">implements</span> ClockConstructor {
    currentTime: <span class="hljs-built_in">Date</span>;
    <span class="hljs-keyword">constructor</span>(h: number, m: number) { }
}
</code></pre>
<p>&#x8FD9;&#x91CC;&#x56E0;&#x4E3A;&#x5F53;&#x4E00;&#x4E2A;&#x7C7B;&#x5B9E;&#x73B0;&#x4E86;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#x65F6;&#xFF0C;&#x53EA;&#x5BF9;&#x5176;&#x5B9E;&#x4F8B;&#x90E8;&#x5206;&#x8FDB;&#x884C;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x3002;
constructor&#x5B58;&#x5728;&#x4E8E;&#x7C7B;&#x7684;&#x9759;&#x6001;&#x90E8;&#x5206;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x5728;&#x68C0;&#x67E5;&#x7684;&#x8303;&#x56F4;&#x5185;&#x3002;</p>
<p>&#x56E0;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x5E94;&#x8BE5;&#x76F4;&#x63A5;&#x64CD;&#x4F5C;&#x7C7B;&#x7684;&#x9759;&#x6001;&#x90E8;&#x5206;&#x3002;
&#x770B;&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#xFF0C;&#x6211;&#x4EEC;&#x5B9A;&#x4E49;&#x4E86;&#x4E24;&#x4E2A;&#x63A5;&#x53E3;&#xFF0C;<code>ClockConstructor</code>&#x4E3A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x6240;&#x7528;&#x548C;<code>ClockInterface</code>&#x4E3A;&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x6240;&#x7528;&#x3002;
&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x6211;&#x4EEC;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;<code>createClock</code>&#xFF0C;&#x5B83;&#x7528;&#x4F20;&#x5165;&#x7684;&#x7C7B;&#x578B;&#x521B;&#x5EFA;&#x5B9E;&#x4F8B;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> ClockConstructor {
    <span class="hljs-keyword">new</span> (hour: <span class="hljs-built_in">number</span>, minute: <span class="hljs-built_in">number</span>): ClockInterface;
}
<span class="hljs-keyword">interface</span> ClockInterface {
    tick();
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createClock</span>(<span class="hljs-params">ctor: ClockConstructor, hour: <span class="hljs-built_in">number</span>, minute: <span class="hljs-built_in">number</span></span>): <span class="hljs-title">ClockInterface</span> </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> ctor(hour, minute);
}

<span class="hljs-keyword">class</span> DigitalClock <span class="hljs-keyword">implements</span> ClockInterface {
    <span class="hljs-keyword">constructor</span>(h: number, m: number) { }
    tick() {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;beep beep&quot;</span>);
    }
}
<span class="hljs-keyword">class</span> AnalogClock <span class="hljs-keyword">implements</span> ClockInterface {
    <span class="hljs-keyword">constructor</span>(h: number, m: number) { }
    tick() {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;tick tock&quot;</span>);
    }
}

<span class="hljs-keyword">let</span> digital = createClock(DigitalClock, <span class="hljs-number">12</span>, <span class="hljs-number">17</span>);
<span class="hljs-keyword">let</span> analog = createClock(AnalogClock, <span class="hljs-number">7</span>, <span class="hljs-number">32</span>);
</code></pre>
<p>&#x56E0;&#x4E3A;<code>createClock</code>&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;<code>ClockConstructor</code>&#x7C7B;&#x578B;&#xFF0C;&#x5728;<code>createClock(AnalogClock, 7, 32)</code>&#x91CC;&#xFF0C;&#x4F1A;&#x68C0;&#x67E5;<code>AnalogClock</code>&#x662F;&#x5426;&#x7B26;&#x5408;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x3002;</p>
<h1 id="&#x7EE7;&#x627F;&#x63A5;&#x53E3;">&#x7EE7;&#x627F;&#x63A5;&#x53E3;</h1>
<p>&#x548C;&#x7C7B;&#x4E00;&#x6837;&#xFF0C;&#x63A5;&#x53E3;&#x4E5F;&#x53EF;&#x4EE5;&#x76F8;&#x4E92;&#x7EE7;&#x627F;&#x3002;
&#x8FD9;&#x8BA9;&#x6211;&#x4EEC;&#x80FD;&#x591F;&#x4ECE;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#x91CC;&#x590D;&#x5236;&#x6210;&#x5458;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#x91CC;&#xFF0C;&#x53EF;&#x4EE5;&#x66F4;&#x7075;&#x6D3B;&#x5730;&#x5C06;&#x63A5;&#x53E3;&#x5206;&#x5272;&#x5230;&#x53EF;&#x91CD;&#x7528;&#x7684;&#x6A21;&#x5757;&#x91CC;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> Shape {
    color: <span class="hljs-built_in">string</span>;
}

<span class="hljs-keyword">interface</span> Square <span class="hljs-keyword">extends</span> Shape {
    sideLength: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">let</span> square = &lt;Square&gt;{};
square.color = <span class="hljs-string">&quot;blue&quot;</span>;
square.sideLength = <span class="hljs-number">10</span>;
</code></pre>
<p>&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#x53EF;&#x4EE5;&#x7EE7;&#x627F;&#x591A;&#x4E2A;&#x63A5;&#x53E3;&#xFF0C;&#x521B;&#x5EFA;&#x51FA;&#x591A;&#x4E2A;&#x63A5;&#x53E3;&#x7684;&#x5408;&#x6210;&#x63A5;&#x53E3;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> Shape {
    color: <span class="hljs-built_in">string</span>;
}

<span class="hljs-keyword">interface</span> PenStroke {
    penWidth: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">interface</span> Square <span class="hljs-keyword">extends</span> Shape, PenStroke {
    sideLength: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">let</span> square = &lt;Square&gt;{};
square.color = <span class="hljs-string">&quot;blue&quot;</span>;
square.sideLength = <span class="hljs-number">10</span>;
square.penWidth = <span class="hljs-number">5.0</span>;
</code></pre>
<h1 id="&#x6DF7;&#x5408;&#x7C7B;&#x578B;">&#x6DF7;&#x5408;&#x7C7B;&#x578B;</h1>
<p>&#x5148;&#x524D;&#x6211;&#x4EEC;&#x63D0;&#x8FC7;&#xFF0C;&#x63A5;&#x53E3;&#x80FD;&#x591F;&#x63CF;&#x8FF0;JavaScript&#x91CC;&#x4E30;&#x5BCC;&#x7684;&#x7C7B;&#x578B;&#x3002;
&#x56E0;&#x4E3A;JavaScript&#x5176;&#x52A8;&#x6001;&#x7075;&#x6D3B;&#x7684;&#x7279;&#x70B9;&#xFF0C;&#x6709;&#x65F6;&#x4F60;&#x4F1A;&#x5E0C;&#x671B;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x5177;&#x6709;&#x4E0A;&#x9762;&#x63D0;&#x5230;&#x7684;&#x591A;&#x79CD;&#x7C7B;&#x578B;&#x3002;</p>
<p>&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x5C31;&#x662F;&#xFF0C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x505A;&#x4E3A;&#x51FD;&#x6570;&#x548C;&#x5BF9;&#x8C61;&#x4F7F;&#x7528;&#xFF0C;&#x5E76;&#x5E26;&#x6709;&#x989D;&#x5916;&#x7684;&#x5C5E;&#x6027;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> Counter {
    (start: <span class="hljs-built_in">number</span>): <span class="hljs-built_in">string</span>;
    interval: <span class="hljs-built_in">number</span>;
    reset(): <span class="hljs-built_in">void</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getCounter</span>(<span class="hljs-params"></span>): <span class="hljs-title">Counter</span> </span>{
    <span class="hljs-keyword">let</span> counter = &lt;Counter&gt;<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">start: <span class="hljs-built_in">number</span></span>): <span class="hljs-title">string</span> </span>{ <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;&apos;</span> };
    counter.interval = <span class="hljs-number">123</span>;
    counter.reset = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ };
    <span class="hljs-keyword">return</span> counter;
}

<span class="hljs-keyword">let</span> c = getCounter();
c(<span class="hljs-number">10</span>);
c.reset();
c.interval = <span class="hljs-number">5.0</span>;
</code></pre>
<p>&#x5728;&#x4F7F;&#x7528;JavaScript&#x7B2C;&#x4E09;&#x65B9;&#x5E93;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F60;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x50CF;&#x4E0A;&#x9762;&#x90A3;&#x6837;&#x53BB;&#x5B8C;&#x6574;&#x5730;&#x5B9A;&#x4E49;&#x7C7B;&#x578B;&#x3002;</p>
<h1 id="&#x63A5;&#x53E3;&#x7EE7;&#x627F;&#x7C7B;">&#x63A5;&#x53E3;&#x7EE7;&#x627F;&#x7C7B;</h1>
<p>&#x5F53;&#x63A5;&#x53E3;&#x7EE7;&#x627F;&#x4E86;&#x4E00;&#x4E2A;&#x7C7B;&#x7C7B;&#x578B;&#x65F6;&#xFF0C;&#x5B83;&#x4F1A;&#x7EE7;&#x627F;&#x7C7B;&#x7684;&#x6210;&#x5458;&#x4F46;&#x4E0D;&#x5305;&#x62EC;&#x5176;&#x5B9E;&#x73B0;&#x3002;
&#x5C31;&#x597D;&#x50CF;&#x63A5;&#x53E3;&#x58F0;&#x660E;&#x4E86;&#x6240;&#x6709;&#x7C7B;&#x4E2D;&#x5B58;&#x5728;&#x7684;&#x6210;&#x5458;&#xFF0C;&#x4F46;&#x5E76;&#x6CA1;&#x6709;&#x63D0;&#x4F9B;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#x4E00;&#x6837;&#x3002;
&#x63A5;&#x53E3;&#x540C;&#x6837;&#x4F1A;&#x7EE7;&#x627F;&#x5230;&#x7C7B;&#x7684;private&#x548C;protected&#x6210;&#x5458;&#x3002;
&#x8FD9;&#x610F;&#x5473;&#x7740;&#x5F53;&#x4F60;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#x7EE7;&#x627F;&#x4E86;&#x4E00;&#x4E2A;&#x62E5;&#x6709;&#x79C1;&#x6709;&#x6216;&#x53D7;&#x4FDD;&#x62A4;&#x7684;&#x6210;&#x5458;&#x7684;&#x7C7B;&#x65F6;&#xFF0C;&#x8FD9;&#x4E2A;&#x63A5;&#x53E3;&#x7C7B;&#x578B;&#x53EA;&#x80FD;&#x88AB;&#x8FD9;&#x4E2A;&#x7C7B;&#x6216;&#x5176;&#x5B50;&#x7C7B;&#x6240;&#x5B9E;&#x73B0;&#xFF08;implement&#xFF09;&#x3002;</p>
<p>&#x5F53;&#x4F60;&#x6709;&#x4E00;&#x4E2A;&#x5E9E;&#x5927;&#x7684;&#x7EE7;&#x627F;&#x7ED3;&#x6784;&#x65F6;&#x8FD9;&#x5F88;&#x6709;&#x7528;&#xFF0C;&#x4F46;&#x8981;&#x6307;&#x51FA;&#x7684;&#x662F;&#x4F60;&#x7684;&#x4EE3;&#x7801;&#x53EA;&#x5728;&#x5B50;&#x7C7B;&#x62E5;&#x6709;&#x7279;&#x5B9A;&#x5C5E;&#x6027;&#x65F6;&#x8D77;&#x4F5C;&#x7528;&#x3002;
&#x9664;&#x4E86;&#x7EE7;&#x627F;&#x81EA;&#x57FA;&#x7C7B;&#xFF0C;&#x5B50;&#x7C7B;&#x4E4B;&#x95F4;&#x4E0D;&#x5FC5;&#x76F8;&#x5173;&#x8054;&#x3002;
&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Control {
    <span class="hljs-keyword">private</span> state: <span class="hljs-built_in">any</span>;
}

<span class="hljs-keyword">interface</span> SelectableControl <span class="hljs-keyword">extends</span> Control {
    select(): <span class="hljs-built_in">void</span>;
}

<span class="hljs-keyword">class</span> Button extends Control <span class="hljs-keyword">implements</span> SelectableControl {
    select() { }
}

<span class="hljs-keyword">class</span> TextBox extends Control {
    select() { }
}

<span class="hljs-comment">// Error: Property &apos;state&apos; is missing in type &apos;Image&apos;.</span>
<span class="hljs-keyword">class</span> Image <span class="hljs-keyword">implements</span> SelectableControl {
    select() { }
}

<span class="hljs-keyword">class</span> Location {

}
</code></pre>
<p>&#x5728;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x91CC;&#xFF0C;<code>SelectableControl</code>&#x5305;&#x542B;&#x4E86;<code>Control</code>&#x7684;&#x6240;&#x6709;&#x6210;&#x5458;&#xFF0C;&#x5305;&#x62EC;&#x79C1;&#x6709;&#x6210;&#x5458;<code>state</code>&#x3002;
&#x56E0;&#x4E3A;<code>state</code>&#x662F;&#x79C1;&#x6709;&#x6210;&#x5458;&#xFF0C;&#x6240;&#x4EE5;&#x53EA;&#x80FD;&#x591F;&#x662F;<code>Control</code>&#x7684;&#x5B50;&#x7C7B;&#x4EEC;&#x624D;&#x80FD;&#x5B9E;&#x73B0;<code>SelectableControl</code>&#x63A5;&#x53E3;&#x3002;
&#x56E0;&#x4E3A;&#x53EA;&#x6709;<code>Control</code>&#x7684;&#x5B50;&#x7C7B;&#x624D;&#x80FD;&#x591F;&#x62E5;&#x6709;&#x4E00;&#x4E2A;&#x58F0;&#x660E;&#x4E8E;<code>Control</code>&#x7684;&#x79C1;&#x6709;&#x6210;&#x5458;<code>state</code>&#xFF0C;&#x8FD9;&#x5BF9;&#x79C1;&#x6709;&#x6210;&#x5458;&#x7684;&#x517C;&#x5BB9;&#x6027;&#x662F;&#x5FC5;&#x9700;&#x7684;&#x3002;</p>
<p>&#x5728;<code>Control</code>&#x7C7B;&#x5185;&#x90E8;&#xFF0C;&#x662F;&#x5141;&#x8BB8;&#x901A;&#x8FC7;<code>SelectableControl</code>&#x7684;&#x5B9E;&#x4F8B;&#x6765;&#x8BBF;&#x95EE;&#x79C1;&#x6709;&#x6210;&#x5458;<code>state</code>&#x7684;&#x3002;
&#x5B9E;&#x9645;&#x4E0A;&#xFF0C;<code>SelectableControl</code>&#x5C31;&#x50CF;<code>Control</code>&#x4E00;&#x6837;&#xFF0C;&#x5E76;&#x62E5;&#x6709;&#x4E00;&#x4E2A;<code>select</code>&#x65B9;&#x6CD5;&#x3002;
<code>Button</code>&#x548C;<code>TextBox</code>&#x7C7B;&#x662F;<code>SelectableControl</code>&#x7684;&#x5B50;&#x7C7B;&#xFF08;&#x56E0;&#x4E3A;&#x5B83;&#x4EEC;&#x90FD;&#x7EE7;&#x627F;&#x81EA;<code>Control</code>&#x5E76;&#x6709;<code>select</code>&#x65B9;&#x6CD5;&#xFF09;&#xFF0C;&#x4F46;<code>Image</code>&#x548C;<code>Location</code>&#x7C7B;&#x5E76;&#x4E0D;&#x662F;&#x8FD9;&#x6837;&#x7684;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Variable Declarations.html" class="navigation navigation-prev " aria-label="Previous page: 变量声明">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Classes.html" class="navigation navigation-next " aria-label="Next page: 类">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"接口","level":"1.3.3","depth":2,"next":{"title":"类","level":"1.3.4","depth":2,"path":"doc/handbook/Classes.md","ref":"./doc/handbook/Classes.md","articles":[]},"previous":{"title":"变量声明","level":"1.3.2","depth":2,"path":"doc/handbook/Variable Declarations.md","ref":"./doc/handbook/Variable Declarations.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Patrick Zhong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"preface.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"TypeScript Handbook","language":"zh-hans","gitbook":">3.0.0","description":"Translation of official TypeScript Handbook"},"file":{"path":"doc/handbook/Interfaces.md","mtime":"2018-10-13T09:48:54.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-13T09:57:42.904Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

